<template>
  <div class="detail">
    <HmHeader  @clickback="fn">
      <template #back>
        <p>返回</p>
      </template>
      面经详情
    </HmHeader>
    <h1>{{ list.stem }}</h1>
    <div class="info">
      <span>{{ list.createdAt }}</span>
      &nbsp;
      <span>|</span>
      &nbsp;
      <span>{{ list.views }} 浏览量</span>
      &nbsp;
      <span>|</span>
      &nbsp;
      <span>{{ list.likeCount }} 点赞数</span>
    </div>

    <div class="qian">
      <img :src="list.avatar" alt="" />
      <span>{{ list.creatorName }}</span>
    </div>

    <div class="content" v-html="list.content"></div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "HmDetail",
  data() {
    return {
      id: this.$route.params.id,
      list: [],
    };
  },
  methods: {
    async getList() {
      const res = await axios({
        url: "http://interview-api-t.itheima.net/h5/interview/show",
        params: {
          id: this.id,
        },
        headers: {
          Authorization: `Bearer ${localStorage.getItem("token")}`,
        },
      });
      console.log(res.data);
      this.list = res.data.data;
    },
    fn() {
      alert("点击了返回");
      this.$router.go(-1);
    },
  },
  created() {
    this.getList(this.id);
  },
};
</script>

<style lang="less" scoped>
.header {
  .van-nav-bar__content {
    display: flex;
  }
}
.qian {
  display: flex;
  align-items: center;

  img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
  }
}
</style>
